set more 1
clear

pause off 

capture log close


global dir_work_tabout  "../outputs/"
global dir_work_figout  "../outputs/"

global dir_work         "../out_data_new" 
global dir_data_out     "../out_datasmm_new" 
global dir_work_out     "../out_datasmm_new" 

global init_age = 15 


******************************************************************
******************************************************************


use NLSY97_PublicData_FinalSample, clear


gen neversmoker = (addiction==0) if addiction != .
label var neversmoker "Never Smoked Regularly as of t-1"

gen dq0 = dq if addiction == 0

gen hgc13more = (hgc >= 13) if hgc != .
label var hgc13more "College_and_more"


label var dq "Smoked Regularly"
label var enroll "Enrolled in School"

*gen dedk = enroll * work_part
label var dedk "Part-time Working while in School"



label var dq0 "Smoking initiation"


label var parents_clg  "Parents are 4-year college graduates"
label var hgc "Years of schooling"

label var dq    "Smoking"
label var neversmoker  "Never smoker"
label var addiction "Years smoked as of t-1"

sort id age
gen firstage = age if dq == 1 & addiction == 0
by id: egen firstAge = min(firstage)
by id: egen maxdq = max(dq) 

label var firstAge "Age of smoking initiation"
hist firstAge if maxdq == 1 & age == 30, discrete percent scheme(s1color) 
graph export $dir_work_figout/Figure_02.pdf, as(pdf) replace 
graph export $dir_work_figout/Figure_02.eps, as(eps) replace 


  
 local xvar "avemeasure_thetac avemeasure_thetan parents_clg"
 

 binscatter hgc firstAge if age == 30 & firstAge <= 25, reportreg controls(`xvar') xtitle(Age of smoking initiation) ytitle(Years of schooling) 
 graph export $dir_work_figout/Figure_01a.pdf, as(pdf) replace 
 graph export $dir_work_figout/Figure_01a.eps, as(eps) replace 
 
 binscatter dq hgc if age == 30, controls(`xvar') xtitle(Years of schooling) ytitle(Smoking rate at age 30) 
 graph export $dir_work_figout/Figure_01b.pdf, as(pdf) replace 
 graph export $dir_work_figout/Figure_01b.eps, as(eps) replace 


